package com.wt.struggle.goodbye.user.activity

import android.os.Bundle
import android.os.Message
import android.widget.SeekBar
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.ProActivity
import com.wt.struggle.goodbye.base.Share
import com.wt.struggle.goodbye.info.NetInfo
import kotlinx.android.synthetic.main.change_text_size_layout.*
import kotlinx.android.synthetic.main.head.*


/**
 * 改变字体大小
 */
class ChangeTextSizeActivity : ProActivity() {

    override fun handler(what: Int, arg1: Int, netInfo: NetInfo) {

    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.change_text_size_layout)
        tvTitle.text = "字体大小"
        tvRight.text = "完成"
        tvRight.setTextColor(resources.getColor(R.color.red))

        getTextSize(50)

        imageBack.setOnClickListener {
            finish()
        }

        tvRight.setOnClickListener {
            // 完成设置
            Share.saveTextSize(this, size!!)

            finish()

        }

        customSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
                getTextSize(p1)
            }

            override fun onStartTrackingTouch(p0: SeekBar?) {

            }

            override fun onStopTrackingTouch(p0: SeekBar?) {
            }

        })
    }


    var arr: ArrayList<Float> = arrayListOf(10f, 12f, 14f, 16f, 18f, 20f, 22f, 24f, 26f, 28f, 30f)
    var size: Float? = 0f

    private fun getTextSize(p1: Int) {
        val position = p1 / 10
        size = arr[position]
        tvYuLan.textSize = size!!

    }
}